package controller

import (
	"fmt"

	"github.com/kataras/iris/websocket"
	"github.com/kataras/neffos"

	"im/service/event"
)

func W() websocket.Events {
	return websocket.Events{

		//连入命名空间
		websocket.OnNamespaceConnect:    event.OnNamespaceConnect(),
		websocket.OnNamespaceConnected:  event.OnNamespaceConnected(),
		websocket.OnNamespaceDisconnect: event.OnNamespaceDisconnect(),

		//连入房间
		websocket.OnRoomJoin:   event.OnGroupJoin(),
		websocket.OnRoomJoined: event.OnGroupJoined(),
		websocket.OnRoomLeft:   event.OnGroupLeft(),
		websocket.OnAnyEvent: func(conn *neffos.NSConn, message neffos.Message) error {
			fmt.Println("receive event")
			return nil
		},
		//群聊
		"group": event.Group(),

		//私聊
		"chat": event.Chat(),
	}
}